<?php
include("include/config.inc.php");
if(isset($_POST['userName']) && strlen($_POST['userName']) > 0 || isset($_POST['passwd']) && strlen($_POST['passwd']) > 0)
{
  $checkLogin = "SELECT userName,password,userType,userId
                   FROM user
                  WHERE userName = '".$_POST['userName']."'
                    AND password = '".md5($_POST['password'])."'
                    AND userType = 'Admin'";
  $checkLoginresult = mysql_query($checkLogin);
  if($userLoginRow = mysql_fetch_array($checkLoginresult))
  {
    $_SESSION['s_activId']   = $userLoginRow['userName'];
    $_SESSION['s_userType']  = $userLoginRow['userType'];
    $_SESSION['s_userId']    = $userLoginRow['userId'];
    if(!$_SESSION['s_urlRedirectDir'])
      header("Location:./index.php");
    else
      header("Location:".$_SESSION['s_urlRedirectDir']);
  }
  else
    echo "Wrong ID of PWD";
}
include("./bottom.php");
$smarty->display("checkLogin.tpl");
?>